<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="saveBtn">保存文件</button>
</body>
<script>
    const fs = require('fs')
    const { dialog } = require('@electron/remote')
    var saveBtn = document.getElementById('saveBtn')
    saveBtn.onclick = function(){
        dialog.showSaveDialog({
            title:'保存文件到本地',
        }).then(result=>{
            // result是一个对象
            console.log(result.filePath)
            // 获得路径之后写入内容
            fs.writeFileSync(result.filePath,'程序员小佟')
        }).catch(err=>{
            console.log(err)
        })
    }
</script>
</html>